/**
 * @program: clms
 * @description:
 * @author: mitu_echo
 * @create: 2021-07-17 14:57
 **/

package com.second.appgateway.config;

import com.second.common.util.RsaUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import javax.annotation.PostConstruct;
import java.security.PrivateKey;
import java.security.PublicKey;

@Data
@ConfigurationProperties(prefix = "second.key")
public class RsaKeyProperties {

    /**
     * 公钥路径
     */
    private String pubKeyPath;
    /**
     * 私钥路径
     */
    private String priKeyPath;
    /**
     * 公钥
     */
    private PublicKey publicKey;
    /**
     * 私钥
     */
    private PrivateKey privatekey;

    @PostConstruct
    public void loadKeyo() throws Exception {
        publicKey = RsaUtil.getPublicKey(pubKeyPath);
        privatekey = RsaUtil.getPrivateKey(priKeyPath);
    }
}
